package core;

public class MessageBuilder {
	 public static final String ONE = ":";
	    public static final String TWO = ";";
	    public static final String NULL = "NULL";
	    public static final String NOT_NULL = "NOT_NULL";

	    public static String BuildLogInMessage(String username, String password) {
	        String message = MessageType.LogIn + ONE + username + TWO + password;
	        return message;
	    }

	    public static String BuildLogInMessage(String username, String password, boolean invisible) {
	        String message = MessageType.LogIn + ONE + username + TWO + password + TWO + invisible;
	        return message;
	    }

	    public static String BuildSendText(String to, String message) {
	        return MessageType.SendText + ONE + to + TWO + message;
	    }

	    public static String BuildSendBuzz(String to) {
	        return MessageType.SendBuzz + ONE + to;
	    }

	    public static String BuildChangeStatus(String newStatus, boolean showBusyIcon) {
	        return MessageType.SendBuzz + ONE + newStatus + TWO + showBusyIcon;
	    }

	    public static String BuildInvisible(boolean invisible) {
	        return MessageType.SendBuzz + ONE + invisible;
	    }

	    public static String BuildLogInResult(boolean error) {
	        if (!error) {
	            return MessageType.LogInResult + ONE + NULL;
	        } else {
	            return MessageType.LogInResult + ONE + NOT_NULL;
	        }
	    }

	    public static String BuildRerportMessage(int slaveId, String slaveAddress, int slavePort, long currentConnections) {

	        return MessageType.SlaveReportMessage + ONE + slaveId + TWO + slaveAddress + TWO + slavePort + TWO + currentConnections;
	    }

	    
	    public static String BuildGetSlaveMessage() {
	        return MessageType.GetSlaveMessage;
	    }

	    public static String BuildLogoutMessage(long userId) {
	        return MessageType.LogOut + ONE + userId;
	    }

	    public static String BuildMessage(String from, String message) {

	        String returnMessage = MessageType.FriendReplyMessage;
	        returnMessage += MessageBuilder.ONE;
	        returnMessage += from;
	        returnMessage += MessageBuilder.TWO;
	        returnMessage += message;

	        return returnMessage;
	    }

	    public static String BuildHaveGotSlaveMessage() {
	        return MessageType.HaveGotSlaveMessage;
	    }

	    public static String BuildFriendList(String string) {
	        return MessageType.FriendList + ONE + string;
	    }

	    public static String BuildUserStatus(String group,String user, String status, String statusMessage) {
	        return MessageType.ListStatus + ONE + group + TWO + user + TWO + status + TWO + statusMessage;
	    }
}
